<?php


namespace app\admin\validate;

use think\Validate;


/**
 * 密码策略验证器
 * Class Password
 * @package app\admin\validate
 * @author Mr.Li
 * @create 2021-07-29 16:22
 */
class Password extends Validate
{

    /**
     * 验证规则
     * @var string[]
     */
    protected $rule = [
        'pwd_type'                      => 'require|in:1,2,3,4,5,6,7',
        'is_pwd_diff_account'           => 'require|between:0,1',
        'is_diff_old_pwd'               => 'require|between:0,1',
        'pwd_max_length'                => 'require|elt:25|egt:6',
        'pwd_min_length'                => 'require|elt:25|egt:6',
        'default_pwd'                   => 'require',
        'is_force_modify'               => 'require|between:0,1',
        'is_lock'                       => 'require|between:0,1',
        'multi_terminal_login'          => 'require|between:0,1',
        'lock_attempt_count'            => 'require|number',
        'lock_option_type'              => 'require|in:1,2',
        'lock_option_attempt_count'     => 'require|number',
        'lock_option_attempt_minute'    => 'require|number'
    ];


    /**
     * 错误信息
     * @var string[]
     */
    protected $message = [
        'pwd_type.require'                      => '密码复杂度类型不能为空',
        'pwd_type.in'                           => '密码复杂度类型设置不正确',
        'is_pwd_diff_account.require'           => '不能与登录名相同设置为空',
        'is_pwd_diff_account.between'           => '不能与登录名相同设置不正确',
        'is_diff_old_pwd.require'               => '新密码不能与原密码相同设置为空',
        'is_diff_old_pwd.between'               => '新密码不能与原密码相同设置不正确',
        'pwd_max_length.require'                => '密码最大长度限制为空',
        'pwd_min_length.require'                => '密码最小长度限制为空',
        'pwd_max_length.egt'                    => '密码最大长度限制不能小于6位',
        'pwd_max_length.elt'                    => '密码最大长度限制不能超过25位',
        'pwd_min_length.egt'                    => '密码最小长度限制不能小于6位',
        'pwd_min_length.elt'                    => '密码最小长度限制不能超过25位',
        'default_pwd.require'                   => '默认密码为空',
        'is_force_modify.require'               => '是否强制重置密码设置为空',
        'is_force_modify.between'               => '否强制重置密码设置不正确',
        'is_lock.require'                       => '登录锁定设置为空',
        'is_lock.between'                       => '登录锁定设置不正确',
        'lock_attempt_count.require'            => '密码尝试次数为空',
        'lock_attempt_count.number'             => '密码尝试次数只能为正整数',
        'lock_option_type.require'              => '密码解锁选项为空',
        'lock_option_type.in'                   => '密码解锁选项不正确',
        'lock_option_attempt_count.require'     => '固定设置尝试锁定次数为空',
        'lock_option_attempt_count.number'      => '固定设置尝试锁定次数只能为正整数',
        'lock_option_attempt_minute.require'    => '固定设置锁定分钟数为空',
        'lock_option_attempt_minute.number'     => '固定设置锁定分钟数只能为正整数',
        'multi_terminal_login.require'          => '多端登录设置不能为空',
        'multi_terminal_login.between'          => '多端登录设置不正确',

    ];


    protected $scene = [
        'update' => ['pwd_type', 'is_pwd_diff_account','is_diff_old_pwd','pwd_max_length',
            'pwd_min_length','default_pwd','is_force_modify','is_lock','multi_terminal_login'],
        'update_lock_option' => ['lock_attempt_count','lock_option_type'],
        'update_lock_option_attempt' => ['lock_option_attempt_count','lock_option_attempt_minute'],

    ];

}

